<?
if (!defined('IN_RJ')) die("Error 404");
if($cmd[1]=="singer" && is_numeric($cmd[2])){
$singer_id=$cmd[2];
if(!$cmd[3]) $cmd[3]=1;
$limit=($cmd[3]-1)*$conf['media_per_page'];
$query="select * from ".$conf['prefix']."singer where singer_id={$singer_id}";
$rq = $DB->query($query);
    if ($singer=$DB->fetch_row($rq)){
		$ro= $tpl->get_tpl('singer_detail');
		$qr_song=$DB->query("SELECT * FROM ".$conf['prefix']."media WHERE m_singer=".$singer_id." ORDER BY m_title_ascii DESC LIMIT {$limit},{$conf['media_per_page']}");
		$qr_tt=$DB->query("SELECT * FROM ".$conf['prefix']."media WHERE m_singer={$singer_id}");
		$total_song=$DB->num_rows($qr_tt);
		if($total_song){
			$j['row']=$tpl->get_block_from_str($ro,"list_song_row",1);
			$i=0;
			$html='';
			while($song=$DB->fetch_row($qr_song)){
			$i++;
				$html .= $tpl->assign_vars($j['row'],
					array(
						'song.TITLE'	=> $song['m_title'],
						'song.ID'		=> $song['m_id'],
						'song.URL'		=> $func->change_link("song",$song['m_id'],$func->title_2_ascii($song['m_title_ascii'])),
						'song.TYPE'		=> "<img src='{TPL_LINK}/".$func->get_data('player',$song['m_type'])."' border=0 >",
						'song.VIEWED'	=> $song['m_viewed'],
						'song.DOWNLOADED' => $song['m_downloaded'],
					)
				);
			}
		
		}
		$singer_name=$func->unhtmlchars($singer['singer_name']);
		$singer_name_ascii=$func->unhtmlchars($singer['singer_name_ascii']);
		$ro=$tpl->assign_vars($ro,
			array(
				'singer.NAME' 	=> $singer_name,
				'singer.ID'		=> $singer_id,
				'singer.IMG'	=> $func->get_img("singer",$singer_id),
				'singer.INFO'	=> $func->unhtmlchars(stripslashes($singer['singer_info'])),
				'singer.TOTAL'  => $total_song,
				'singer.PAGES'	=> $func->viewpages($total_song,$conf['media_per_page'],$cmd[3],$func->title_2_ascii($singer_name_ascii)),
				
			)
		);
		$ro=$tpl->assign_blocks_content($ro,array(
			'list_song'	=> $html,
			)
		);
	}
	else  $ro=box_announcement($lang['no_data']);
		$title_web_bar=$singer_name;
		$title_ascii_web_bar=$singer_name_ascii;
		$main_content=$ro;
}

if($cmd[1]=="singer" && $cmd[2]=="domestic"){
if(!$cmd[3]) $cmd[3]=1;
$limit=($cmd[3]-1)*$conf['media_per_page'];
$list_singer_title_bar=$func->title_2_ascii($lang['list_domestic_singer'],true);
$query=$DB->query("select * from ".$conf['prefix']."singer where singer_type=1 order by singer_name_ascii asc limit {$limit},{$conf['media_per_page']}");
$q_tt=$DB->query("select * from ".$conf['prefix']."singer where singer_type=1");
$total=$DB->num_rows($q_tt);
	if($total){
		$ro=$tpl->get_tpl("list_singer");
		$html='';
		$t['row']=$tpl->get_block_from_str($ro,'list_singer.row',1);
		while($singer=$DB->fetch_row($query)){
			$html.=$tpl->assign_vars($t['row'],array(
					'singer.NAME'	=> $singer['singer_name'],
					'singer.URL'	=> $func->change_link("singer",$singer['singer_id'],$func->title_2_ascii($singer['singer_name_ascii'])),
					'singer.IMG'	=> $func->get_img("singer",$singer['singer_id']),
				
				)
			);
		}
		$ro=$tpl->assign_vars($ro,array(
				'singer.TOTAL'	=> "{$lang['total']} <b>{$total}</b> {$lang['singer']}",
				'singer.PAGES'	=> $func->viewpages($total,$conf['media_per_page'],$cmd[3],$list_singer_title_bar),
			)
		);
	
		$ro=$tpl->assign_blocks_content($ro,array(
				'list_singer'	=> $html,
				)
		);
	}
	else $ro=box_announcement($lang['no_data']);
		$title_web_bar=$lang['list_domestic_singer'];
		$title_ascii_web_bar=$list_singer_title_bar;
		$main_content=$ro;

}
if($cmd[1]=="singer" && $cmd[2]=="foreign"){
if(!$cmd[3]) $cmd[3]=1;
$limit=($cmd[3]-1)*$conf['media_per_page'];
$list_singer_title_bar=$func->title_2_ascii($lang['list_foreign_singer'],true);
$query=$DB->query("select * from ".$conf['prefix']."singer where singer_type=2 order by singer_name_ascii asc limit {$limit},{$conf['media_per_page']}");
$q_tt=$DB->query("select * from ".$conf['prefix']."singer where singer_type=2");
$total=$DB->num_rows($q_tt);
	if($total){
		$ro=$tpl->get_tpl("list_singer");
		$html='';
		$t['row']=$tpl->get_block_from_str($ro,'list_singer.row',1);
		while($singer=$DB->fetch_row($query)){
			$html.=$tpl->assign_vars($t['row'],array(
					'singer.NAME'	=> $singer['singer_name'],
					'singer.URL'	=> $func->change_link("singer",$singer['singer_id'],$func->title_2_ascii($singer['singer_name_ascii'])),
					'singer.IMG'	=> $func->get_img("singer",$singer['singer_id']),
				
				)
			);
		}
		$ro=$tpl->assign_vars($ro,array(
				'singer.TOTAL'	=> "{$lang['total']} <b>{$total}</b> {$lang['singer']}",
				'singer.PAGES'	=> $func->viewpages($total,$conf['media_per_page'],$cmd[3],$list_singer_title_bar),
			)
		);
	
		$ro=$tpl->assign_blocks_content($ro,array(
				'list_singer'	=> $html,
				)
		);
	}
	else $ro=box_announcement($lang['no_data']);
		$title_web_bar=$lang['list_foreign_singer'];
		$title_ascii_web_bar=$list_singer_title_bar;
		$main_content=$ro;

}
?>
